package com.pingan.agentbank.aaos.testme;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.json.XML;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

public class JsonTest {

    @Test
    public void method1(){
        String string = "{\"application_no\":\"6a2292c4-790c-4a39-9094-140a7ea23aa8\",\"party_no\":\"9537\",\"expand_branch\":\"\",\"chinese_name\":\"李小明\",\"sex\":\"M\",\"birth_date\":\"19911125\",\"owner_name\":\"lixiaoming\",\"mobile\":\"15738885696\",\"email\":\"\",\"country_citizen\":\"\",\"global_type\":\"1\",\"global_id\":\"410823199111070000\",\"global_eff_enddate\":\"20271115\",\"global_eff_flag\":\"\",\"issuing_authority\":\"\",\"marital_status\":\"1\",\"children_flag\":\"1\",\"education\":\"02\",\"phone_area\":\"0371\",\"home_phome\":\"7683791\",\"address1\":\"城市经典玉树\",\"address2\":\"城市经典玉树\",\"address3\":\"城市经典玉树\",\"address4\":\"城市经典玉树\",\"postcode\":\"454950\",\"residential_type\":\"1\",\"companyname\":\"住建局\",\"departname\":\"审计科\",\"post\":\"科长\",\"employer_add1\":\"上海市黄浦路111号\",\"employer_add2\":\"上海市黄浦路111号\",\"employer_add3\":\"上海市黄浦路111号\",\"employer_add4\":\"上海市黄浦路111号\",\"employer_postcode\":\"454950\",\"employer_phone_areano\":\"0371\",\"employer_phone\":\"7758258\",\"company_type\":\"01\",\"working_years\":\"20\",\"annual_income\":\"1000\",\"ex_working_years\":\"2\",\"immidediate_name\":\"王大明\",\"immidediate_relation\":\"2\",\"immidediate_mobile\":\"15738518183\",\"other_name\":\"周杰伦\",\"other_relation\":\"2\",\"other_mobile\":\"13782850669\",\"car_number\":\"\",\"car_brand\":\"\",\"bank_account\":\"123\",\"mainBillingPostType\":\"电子账单\",\"send_addr_type\":\"1\",\"salses_name\":\"王岐山\",\"sales_code\":\"001\",\"sales_company_code\":\"\",\"application_tool\":\"\",\"applytime\":\"\",\"upload_cardtye\":\"\",\"creditcardCategory\":\"信用卡\",\"creditcardType\":\"白金卡\",\"collection_no\":\"11111\",\"bar_code\":\"123456\",\"swimmingGold\":\"0.50\",\"source_code\":\"\",\"affinityCode\":\"中国人民银行\",\"applicationFlag\":\"\",\"positionname\":\"\",\"referrer_globalid\":\"\",\"referrer_mobile\":\"\",\"channel_id\":\"\",\"expand_source\":\"\",\"monthly_mortgage_payment\":\"\",\"payment_limit_type\":\"\",\"campaign_code\":\"\",\"giveCardCity \":\"\",\"referrer_name\":\"\",\"expand_no\":\"\",\"agentunit\":\"UCCB\",\"reside_years\":\"50\",\"reside_add1\":\"张江以南\",\"reside_add2\":\"张江以南\",\"reside_add3\":\"张江以南\",\"reside_add4\":\"张江以南\",\"reside_postcode\":\"9999\",\"job_code\":\"023\",\"job_description\":\"032\",\"certification_type\":\"中国税收居民\",\"isOwnerMobile\":\"1\",\"ownerMobileStatus\":\"2\",\"useTimeScore\":\"2\",\"audit_result\":\"通过\",\"amount\":\"1000\",\"refuse_code\":\"\"}\n";
        JSONObject jsonObject = JSON.parseObject(string);
        System.out.println(jsonObject.getString("application_no"));
        System.out.println(jsonObject.getString("expand_branch")==null);
        System.out.println(jsonObject.getString("expand_branch").equals(""));
        System.out.println(jsonObject.getString("777")==null);

        String xml = XML.toString(string);
        System.out.println(xml);

    }

    @Test
    public void mehod2(){

        String str = "creditcardType,creditcardCategory,affinityCode,channel_id,application_no,chinese_name,owner_name,sex,global_type,global_id,birth_date,education,marital_status,residential_type,postcode,reside_years,giveCardCity,mobile,email,companyname,employer_postcode,employer_phone,job_code,send_addr_type,mainBillingPostType,immidediate_name,immidediate_relation,immidediate_mobile,audit_result,home_addr_province,home_addr_city,home_addr_region,home_addr_main,employer_addr_province,employer_addr_city,employer_addr_region,employer_addr_main";
        Map<String,String> map = new HashMap<>();
        String[] fields = str.split(",");
        for (String s:fields){
            map.put(s,"1");
        }

        String json = JSON.toJSONString(map);
        System.out.println(json);

    }


}
